﻿using SD.Infrastructure.WPF.Caliburn.Aspects;
using SD.Infrastructure.WPF.Caliburn.Base;
using System.Windows;

namespace SlamDunk.MES.Client.ViewModels.Execution
{
    /// <summary>
    /// 工单实际参数添加ViewModel
    /// </summary>
    public class AddActualParametersViewModel : ScreenBase
    {
        #region # 字段及构造器

        /// <summary>
        /// 依赖注入构造器
        /// </summary>
        public AddActualParametersViewModel()
        {
        }
        #endregion

        #region 属性

        #region 参数编号
        /// <summary>
        /// 参数编号
        /// </summary>
        [DependencyProperty]
        public string ParameterNo { get; set; }
        #endregion

        #region 参数名称
        /// <summary>
        /// 参数名称
        /// </summary>
        [DependencyProperty]
        public string ParameterName { get; set; }
        #endregion

        #region 对应变量编号
        /// <summary>
        /// 对应变量编号
        /// </summary>
        [DependencyProperty]
        public string RelatedVariableNo { get; set; }
        #endregion

        #region 参数值
        /// <summary>
        /// 参数值
        /// </summary>
        [DependencyProperty]
        public decimal Value { get; set; }
        #endregion

        #region 值单位编号
        /// <summary>
        /// 值单位编号
        /// </summary>
        [DependencyProperty]
        public string ValueUnitNo { get; set; }
        #endregion

        #region 排序
        /// <summary>
        /// 排序
        /// </summary>
        [DependencyProperty]
        public int Sort { get; set; }
        #endregion

        #region 描述
        /// <summary>
        /// 描述
        /// </summary>
        [DependencyProperty]
        public string Description { get; set; }
        #endregion
        #endregion

        #region 方法

        #region 提交 —— async void Submit()
        /// <summary>
        /// 提交
        /// </summary>
        public async void Submit()
        {
            #region # 验证
            if (string.IsNullOrEmpty(ParameterNo))
            {
                MessageBox.Show("请输入参数编号！", "警告", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            if (string.IsNullOrEmpty(ParameterName))
            {
                MessageBox.Show("请输入参数名称！", "警告", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            if (string.IsNullOrEmpty(RelatedVariableNo))
            {
                MessageBox.Show("请输入对应变量编号！", "警告", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            if (string.IsNullOrEmpty(ValueUnitNo))
            {
                MessageBox.Show("请输入值单位编号！", "警告", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            #endregion
            await base.TryCloseAsync(true);
        }
        #endregion
        #endregion

    }
}
